package com.forlove.app.qselect.login.entity;

import com.forlove.app.qselect.login.widget.pickerview.model.IPickerViewData;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yjl on 2017/10/27.
 */

public class EmotionEntity implements IPickerViewData {
    public DataInfoEntity emotion;
    public List<DataInfoEntity> dataInfoEntities = new ArrayList<>();

    public DataInfoEntity getEmotion() {
        return emotion;
    }

    public void setEmotion(DataInfoEntity emotion) {
        this.emotion = emotion;
    }

    public List<DataInfoEntity> getDataInfoEntities() {
        return dataInfoEntities;
    }

    public void setDataInfoEntities(List<DataInfoEntity> dataInfoEntities) {
        this.dataInfoEntities = dataInfoEntities;
    }

    @Override
    public String getPickerViewText() {
        return emotion.getName();
    }

    /**
     * 根据id获取当前子情感状态
     *
     * @param emotionId
     * @return
     */
    public DataInfoEntity getChildEmotion(int emotionId) {
        if (emotionId == emotion.id) {
            return emotion;
        }
        DataInfoEntity child = null;
        for (int i = 0; i < dataInfoEntities.size(); i++) {
            DataInfoEntity dataInfoEntity = dataInfoEntities.get(i);
            if (dataInfoEntity.id == emotionId) {
                child = dataInfoEntity;
                child.select = i;
                break;
            }
        }
        return child;
    }
}
